import api from '@/utils/http'
import type { BaseResult, PageParams, PageResult } from '@/types/axios.d'
import type { BrandType } from '@/api/model/brandModel'

// 品牌管理查询
export function getBrandList(
  data: PageParams & { brandName?: string }
): Promise<BaseResult<PageResult<BrandType>>> {
  return api.post({
    url: '/brand/getAll',
    data
  })
}

// 新增品牌
export function addBrand(data: {
  brandName: string
  brandLogo: string
}): Promise<BaseResult<number>> {
  return api.post({
    url: '/brand/save',
    data
  })
}

// 更新品牌
export function updateBrand(data: {
  id: number
  brandName: string
  brandLogo: string
}): Promise<BaseResult<null>> {
  return api.post({
    url: '/brand/update',
    data
  })
}

// 删除品牌
export function deleteBrand(data: { id: number }): Promise<BaseResult<number>> {
  return api.post({
    url: '/brand/delete',
    data
  })
}

// 品牌详情查询
export function getBrandById(data: { id: number }): Promise<BaseResult<BrandType>> {
  return api.post({
    url: '/brand/getById',
    data
  })
}
